//
// Created by 文道江 on 16/1/12.
// Copyright (c) 2016 文道江. All rights reserved.
//

#import "BaiduMTJPlugin.h"


@implementation BaiduMTJPlugin {
    NSString *_baiduMobAppKey;
}

- (void)pluginInitialize {

    // 初始化配置
    _baiduMobAppKey = [HybridBridge defaultHybridBridge].appInfo[@"baiduMobAppKey"];
    BaiduMobStat *statTracker = [BaiduMobStat defaultStat];
    statTracker.shortAppVersion = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"];

    if (IS_DEBUG){
        statTracker.enableDebugOn = YES;
    }

    [statTracker startWithAppId:_baiduMobAppKey];

    [[HybridEventBus defaultEventBus] subscribe:@"shouldStartLoadWithRequest" UsingBlock:^(NSNotification *notification) {
        NSURLRequest *request = notification.userInfo[@"request"];
        UIWebView *webView1 = notification.userInfo[@"webView"];
        if (self.webView == webView1){
            if (request){
                [statTracker webviewStartLoadWithRequest:request];
            }
            NSLog(@"....shouldStartLoadWithRequest %@ ", notification.userInfo);
        }
    }];
}


@end